home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
8bitfiles.net/archives
/
archives.tar
/
archives
/
compuserve-file-archive
/
05 Programming
/
SHLRAM.SDA
/
DPRINTF.A
< prev
next >
Wrap
Text File
|
2019-04-13
|
7KB
|
519 lines
;
; SHELLRAM
;
; ┬Y: ┴DRIAN ╨EPPER
; ╘ORONTO, ╧NTARIO
;
; BASED ON, BUT HEAVILY MODIFIED FROM
; THE ╨RO-╠INE/╙PINNAKER
; ├ ╨╧╫┼╥/╨╧╫┼╥ ├ SHELL FOR THE
; ├OMMODORE 64 HOME COMPUTER.
;
; ╘HE SHELL WAS MODIFIED TO REDUCE
; THE SIZE OF THE CODE, AND ARRANGE
; THINGS SO MEMORY PAGE 22 (HEX $16)
; WILL BE FREE FOR USE AS A "╥┴═DISK
; ╔NTERFACE ╨AGE", FOR USE WITH THE
; ├OMMODORE 1764 256╦ ╥┴═ EXPANDER
; FOR THE ├OMMODORE 64
;
; ╘HIS (BASICALLY) ALLOWS ALL PROGRAMS
; DESIGNED TO RUN UNDER THE SHELL TO
; OPERATE WITH THE ╥┴═ DISK
;
;
; DPRINTF.A - PRINTF IMPLEMENTATION
; ROUTINES
;
;
; ╔T MUST BE IN THE SHELL TO SAVE ├
; PROGRAM SIZE. ╔T WOULD BE NICE TO BE
; ABLE TO LINK IN THE VERSION FROM THE
; DISTRIBUTION LIBRARY DISK, BUT SEVERAL
; PROBLEMS PREVENT THIS, SO THIS VERSION
; IS PROVIDED HERE.
;
; ALSO GETNUM ROUTINE USED BY SHELL
;
.REF STDOUFL
;
.REF ARGSTK
;
.REF CHKOUT
.REF CLRCHN
.REF CHROUT
;
.DEF DPRINTF
.DEF DSPRINT
.DEF DFPRINT
;
.DEF GETNUM
;
.REF C$FUNCTñINIT
.REF PRFBUF ; MUST BE FORCED ABOVE $1600 TO $16FF PAGE
; ; ALSO WE COMBINE WITH 'STRAC' TO SAVE SPACE
;
FLTBUF=$0100 ; BASIC ROUTINE FLOATING POINT CONVERSION BUFFER
; ; LIVES IN THIS PRECARIOUS PLACE!
;
DSPRINT JSR C$FUNCTñINIT ; SPRINTF
LDA ARGSTK,X
STA $FB ; PTR TO OUTPUT STR IN FB,FC
INX
LDA ARGSTK,X
STA $FC
INX
STX $4C
LDA #$00
JMP ESPRINT
;
DPRINTF JSR C$FUNCTñINIT ; PRINTF
STX $4C
LDA #$02
BNE T0160F
;
DFPRINT JSR C$FUNCTñINIT ; FPRINTF
LDA ARGSTK,X
INX
INX
STX $4C
T0160F CMP #2
BNE T0170F
LDX STDOUFL
BNE T0170F
JSR CLRCHN
JMP EPRINTF
T0170F TAX
JSR CHKOUT
EPRINTF LDA #$01
ESPRINT STA $4D ; FLAG; 0 MEANS SPRINTF
LDX $4C
LDA ARGSTK,X
INX
STA $FD ; FMT STR ADDR IN FD,FE
LDA ARGSTK,X
INX
STA $FE
STX $4C
LDY #$FF
PRFMNLP INY
LDA ($FD),Y
BNE T0190F
LDY $4D
BNE T0180F
STA ($FB),Y
T0180F JMP CLRCHN
T0190F CMP #'%
BNE PRFNPER
JSR PRFPERC
LDA ($FD),Y
CMP #'D
BNE PRFNOTD
JSR PRFD
JMP PRFPARG
PRFNOTD CMP #'U
BNE PRFNOTU
JSR PRFU
JMP PRFPARG
PRFNOTU CMP #'X
BNE PRFNOTX
JSR PRFX
JMP PRFPARG
PRFNOTX CMP #'O
BNE PRFNOTO
JSR PRFO
JMP PRFPARG
PRFNOTO CMP #'C
BNE PRFNOTC
JSR PRFC
JMP PRFPARG
PRFNOTC CMP #'S
BNE PRFNOTS
JSR PRFS
JMP PRFPARG
PRFNOTS CMP #'F
BNE PRFNOTF
JSR PRFF
JMP PRFPARG
PRFNOTF CMP #'G
BNE PRFNOTG
JSR PRFG
JMP PRFPARG
PRFNOTG CMP #0
BEQ PRFNULB
JSR PRFPFC
JMP PRFMNLP
PRFNULB DEY
JMP PRFMNLP
PRFNPER JSR PRFPFC
JMP PRFMNLP
PRFPFC STY $51
LDY $4D
BEQ T0200F
LDY $51
JMP CHROUT
T0200F STA ($FB),Y
INC $FB
BNE T0210F
INC $FC
T0210F LDY $51
RTS
PRFGARG STY $4B
LDX $4C
LDA ARGSTK,X
STA $5A
INX
LDA ARGSTK,X
STA $5B
INX
STX $4C
LDA #$00
STA $58
RTS
PRFU LDA #$01
BNE T0220F
PRFD LDA #$00
T0220F STA $51
JSR PRFGARG
STA $54
LDA $5B
BPL T0240F
LDY $51
BNE T0240F
EOR #$FF
STA $5B
LDA $5A
EOR #$FF
STA $5A
INC $5A
BNE T0230F
INC $5B
T0230F LDA #'-
STA PRFBUF
INC $54
T0240F LDX #$04
T0250B LDY #$00
T0260B LDA $5A
SEC
SBC T0310F,X
STA $51
LDA $5B
SBC T0320F,X
BCC T0270F
STA $5B
LDA $51
STA $5A
INY
BNE T0260B
T0270F TYA
BEQ T0280F
STA $58
T0280F LDA $58
BEQ T0290F
LDA PRFHEXT,Y
LDY $54
STA PRFBUF,Y
INC $54
T0290F DEX
BPL T0250B
LDX $54
PRFNRTS LDY $4B
LDA $58
BNE T0300F
LDA #'0
STA PRFBUF,X
INX
T0300F RTS
T0310F .BYTE $01,$0A,$64,$E8,$10
T0320F .BYTE $00,$00,$00,$03,$27
PRFG LDA $1
PHA
ORA #$01
STA $1
STY $4B
CLC
LDA #$3C
ADC $4C
LDY #$03
JSR $BBA2
JSR $BDDD
LDY #$00
LDX #$00
PRFGLP LDA FLTBUF,Y
BEQ T0340F
CMP #$20
BEQ T0330F
STA PRFBUF,X
INX
T0330F INY
JMP PRFGLP
T0340F CLC
LDA $4C
ADC #$05
STA $4C
LDY $4B
PLA
STA $1
RTS
PRFF LDA $1
PHA
ORA #$01
STA $1
STY $4B
CLC
LDA #$3C
ADC $4C
LDY #$03
JSR $BBA2
JSR $BDDD
LDA #0
STA $56
STA $55
STA $53
LDA $50
BNE T0350F
INC $56
T0350F BPL T0360F
LDA #6
STA $50
T0360F LDY #0
LDX #0
PRFFLP LDA FLTBUF,Y
BEQ T0400F
CMP #$20
BEQ T0390F
CMP #$45
BNE T0370F
JSR PRFEXP
LDA #0
STA $55
INC $53
LDA #$45
T0370F STA $51
LDA $55
BEQ T0375F
LDA $50
BEQ T0390F
DEC $50
T0375F LDA $51
CMP #$2E
BNE T0380F
LDA $56
BNE T0400F
INC $55
T0380F LDA $51
STA PRFBUF,X
INX
T0390F INY
JMP PRFFLP
T0400F CLC
LDA $4C
ADC #5
STA $4C
LDY $4B
PLA
STA $1
PRFEXP LDA $56
BNE T0430F
LDA $53
BNE T0430F
LDA $55
BNE T0410F
LDA #$2E
STA PRFBUF,X
INX
T0410F LDA $50
BEQ T0430F
LDA #$30
T0420B STA PRFBUF,X
INX
DEC $50
BNE T0420B
T0430F RTS
PRFX JSR PRFGARG
LDX #0
LDA #4
STA $5C
T0440B LDA $5B
LSR A
LSR A
LSR A
LSR A
TAY
BNE T0450F
LDA $58
BEQ T0460F
T0450F LDA PRFHEXT,Y
STA PRFBUF,X
INX
STX $58
T0460F LDY #4
T0470B ASL $5A
ROL $5B
DEY
BNE T0470B
DEC $5C
BNE T0440B
JMP PRFNRTS
PRFHEXT .BYTE "0123456789ABCDEF"
PRFO JSR PRFGARG
LDX #0
LDA $5B
BPL T0480F
LDA #$31
STA PRFBUF
INX
STX $58
T0480F LDA #$05
STA $5C
T0490B LDA $5B
LSR A
LSR A
LSR A
LSR A
AND #7
TAY
BNE T0500F
LDA $58
BEQ T0510F
T0500F LDA PRFHEXT,Y
STA PRFBUF,X
INX
STX $58
T0510F LDY #$03
T0520B ASL $5A
ROL $5B
DEY
BNE T0520B
DEC $5C
BNE T0490B
JMP PRFNRTS
PRFC LDX $4C
LDA ARGSTK,X
STA PRFBUF
INX
INX
STX $4C
LDX #1
RTS
PRFS STY $4B
LDX $4C
LDA ARGSTK,X
STA $20
INX
LDA ARGSTK,X
STA $21
INX
STX $4C
LDY #0
T0530B LDA $50
BEQ T0540F
LDA ($20),Y
BEQ T0540F
STA PRFBUF,Y
INY
DEC $50
BNE T0530B
T0540F TYA
TAX
LDY $4B
RTS
PRFPERC LDA #0 ; PRINTF, PERCENT FOUND¬
STA $4E
INY
LDA ($FD),Y
CMP #$2D
BNE T0550F
INC $4E
INY
T0550F LDA ($FD),Y
CMP #$30
BEQ T0560F
LDA #$20
T0560F STA $52
JSR PRFGFLD
STA $4F
LDA ($FD),Y
CMP #'.
BNE T0570F
INY
JSR PRFGFLD
JMP T0580F
T0570F LDA #$FF
T0580F STA $50
LDA ($FD),Y
CMP #$4C
BNE T0590F
INY
T0590F RTS
PRFGFLD LDA ($FD),Y
CMP #'*
BNE T0600F
LDX $4C
LDA ARGSTK,X
INX
INX
STX $4C
INY
RTS
;
T0600F JMP PFGNUM ;; AND RETURN
;
PRFPARG STX $54
LDA $4E
BNE T0630F
JSR PRFOUT
T0630F LDX #0
T0640F CPX $54
BEQ T0650F
LDA PRFBUF,X
JSR PRFPFC
INX
BNE T0640F
T0650F LDA $4E
BEQ T0660F
JSR PRFOUT
T0660F JMP PRFMNLP
PRFOUT SEC
LDA $4F
SBC $54
BCC T0680F
TAX
BEQ T0680F
T0670F LDA $52
JSR PRFPFC
DEX
BNE T0670F
T0680F RTS
;
;
; GETNUM - TURN PTR IN X,Y TO (SMALL) NUMBER IN A
; USES $FD,$FE, $5A,$5B (AND Y AND A)
;
GETNUM = *
STX $FD
STY $FE
LDY #0
;
; PFGNUM - SPECIAL ENTRY FOR PRINTF USE ONLY
; ASSUMES $FD,$FE AND Y SET UP ALREADY
;
PFGNUM LDA #$00
STA $5A
T0610B LDA ($FD),Y
EOR #'0 ;; ASSUMES ASCII
CMP #10
BCS T0620F
STA $5B
LDA $5A
ASL $5A
ASL $5A
ADC $5A
ASL A
ADC $5B
STA $5A
INY
BNE T0610B
T0620F LDA $5A
RTS